home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 6 / The Arsenal Files 6 (Arsenal Computer).ISO / games / netspec.zip / NETSPEC.TXT < prev   
Text File  |  1996-01-01  |  7KB  |  179 lines

  1.  
  2. Game and Address Discovery Packets
  3.  
  4. for Descent Registered v1.0.
  5. Robert Huebner
  6.  
  7. The following information is provided for informational 
  8. purposes only.  Parallax and Interplay make no guarantees as to 
  9. the completeness or accuracy of this information, and the 
  10. information is subject to change in future versions of Descent 
  11. with no guarantee of updating this document.  This is not an 
  12. official document of either company and is inteded simply as an 
  13. aid to the Descent user community in developing useful 
  14. utilities.
  15.  
  16. Note that the format described here is not valid for Shareware 
  17. versions of Descent.  The two versions use a different network 
  18. packet structure and different socket numbers, so an 
  19. application written to work with registered versions of Descent 
  20. will not work with shareware ones.
  21.  
  22. Overview:
  23.  
  24. Because discovery of active games and so on uses IPX broadcast 
  25. packets, this opens the door for home-brew programs to display 
  26. active games and so on.  And because there is actually more 
  27. information in these discovery packets than is currently used 
  28. in the game itself, there is a great deal of interesting 
  29. information that can be displayed about an active game.  Some 
  30. examples of info that could be displayed are:
  31.  
  32. current game scores (kills, killed, points, etc)
  33. players in an active game (callsigns)
  34. level the game is on
  35. mission the game is using
  36. time spent in the current level
  37. IPX addresses for all the active players
  38. team membership
  39.  
  40. All this information can also be shown for closed games.
  41.  
  42. fix types are 32-bit fixed point values with 16-bit mantissa.
  43.  
  44. All packets sent/received are assumed to contain a standard ECB 
  45. and IPX header.  In addition, the first 4 bytes are a packet 
  46. sequence number not of interest to this specification.  
  47. Therefore each structure described here begins on the 5th byte 
  48. of the data portion of the packet, or 32 bytes from the start 
  49. of the packet.
  50.  
  51. The game information is stored in a structure referred to 
  52. internally as Netgame_info.  Here is the structure of 
  53. netgame_info:
  54.  
  55. WARNING: Do not flood the network with broadcast packets in 
  56. order to get this game information.  It will slow down the 
  57. games and generally irritate everyone on the network.  If you 
  58. don't know how to add a sleep time to the polling loop of a 
  59. network application, please stop reading and leave the coding 
  60. to someone else!  Playing with raw IPX broadcasts is not a good 
  61. way to introduce yourself to network programming.
  62.  
  63. The following struct is used as an element in the two basic 
  64. structures needed to implement this system:
  65.  
  66. typedef struct netplayer_info {
  67.     char        callsign[9]; 
  68.     ubyte        server[4];  (these are not the local target addresses)
  69.     ubyte        node[6];
  70.     ushort        socket;
  71.     byte         connected;
  72. } netplayer_info;
  73.  
  74. Values for 'connected' field:
  75. #define CONNECT_DISCONNECTED        0    (Player was in game but left)
  76. #define CONNECT_PLAYING            1    (Player is in game and playing)
  77. #define CONNECT_WAITING            2    (Player is waiting to start the next level)
  78. #define CONNECT_DIED_IN_MINE        3    (Player died in mine)
  79. #define CONNECT_FOUND_SECRET        4    (Player exited mine via secret exit)
  80. #define CONNECT_ESCAPE_TUNNEL        5    (Player is flying thru escape tunnel)
  81. #define CONNECT_END_MENU        6    (Player is looking at the kill list or bonus)
  82.  
  83. typedef struct netgame_info {
  84.     ubyte        type; // Always 37 decimal for this packet type
  85.     char        game_name[16];
  86.     char        team_name[2][9];
  87.     ubyte        gamemode; (see NETGAME_XXX defines)
  88.     ubyte        difficulty; (0-4)
  89.     ubyte         game_status;
  90.     ubyte        numplayers; // how many active players
  91.     ubyte        max_numplayers; (4 or 8, depending on mode)
  92.     ubyte        game_flags; (see NETGAME_FLAG_XXX defines)
  93.     netplayer_info    players[8];
  94.     int        locations[8]; // starting locations (not always valid)
  95.     short        kills[8][8]; // array of who-killed-who
  96.     int        levelnum; // -1 = secret #1
  97.     ubyte        protocol_version; // 2 for Registered
  98.     ubyte        team_vector; // bitvector, 0 = blue, 1 = red.
  99.     ushort        segments_checksum;
  100.     short        team_kills[2];
  101.     short        killed[8];
  102.     short        kills[8];
  103.     fix        level_time;
  104.     fix        control_invul_time; // while level time < this, no damage to controlcen
  105.     int         monitor_vector; // which monitors are exploded, 32-bit bitvector
  106.     int        player_score[8]; // valid only during coop games
  107.     ubyte        player_flags[8]; // can get info about keys players have
  108.     char        mission_name[9]; // filename of mission
  109.     char        mission_title[22]; // title of mission
  110. } netgame_info;
  111.  
  112. // Values for game_status field:
  113. #define NETSTAT_MENU        0
  114. #define NETSTAT_PLAYING        1
  115. #define NETSTAT_BROWSING    2
  116. #define NETSTAT_WAITING        3
  117. #define NETSTAT_STARTING    4
  118. #define NETSTAT_ENDLEVEL    5
  119.  
  120. // Values for game_flags field
  121. #define NETGAME_FLAG_CLOSED     1
  122. #define NETGAME_FLAG_SHOW_ID    2 // Not currently in use
  123. #define NETGAME_FLAG_SHOW_MAP     4
  124.  
  125. // Values for gamemode field
  126. #define NETGAME_ANARCHY        0
  127. #define NETGAME_TEAM_ANARCHY    1
  128. #define NETGAME_ROBOT_ANARCHY    2
  129. #define NETGAME_COOPERATIVE    3
  130.  
  131. Obtaining a netgame packet:
  132.  
  133. To obtain a netgame packet for each active network game, the 
  134. program must broadcast a packet the says "Tell me about your 
  135. netgame".  A representative from each actively running or 
  136. forming netgame will reply (not broadcast) the structure shown 
  137. above to the requestor.  Also, when game information changes or 
  138. when a new game is started, the netgame structure will be 
  139. broadcast on the socket.
  140.  
  141. Socket numbers begin at a default of  hex 5100, adding the 
  142. value of the -socket command line param to this base for 
  143. alternate sockets.
  144.  
  145. To request netgame_info packets, your application needs to send 
  146. a filled-in "sequence_packet".  To broadcast a packet on IPX 
  147. you can send to local target 0xff, 0xff, 0xff, 0xff, 0xff, 
  148. 0xff.  My suggestion is do this no more than once every minute 
  149. or so to avoid loading the network and burdening the machines 
  150. playing the game.  Or better yet do it only once on-demand.  
  151. After you broadcast this packet you should get between 0 and 4 
  152. replies from active netgames within 1 or 2 seconds.
  153.  
  154. typedef struct sequence_packet {
  155.     ubyte            type; // 36 decimal for this situation!
  156.     netplayer_info        player;
  157. } sequence_packet;
  158.  
  159. Fields that should be filled in are player.node, and 
  160. player.server.  The node are server must be filled in since the 
  161. reply is not broadcast.   Type must be set to 36 decimal.  
  162. Player.callsign can be ignored.
  163.  
  164. Make sure all fields in this broadcast are set correctly to 
  165. avoid problems!
  166.  
  167. Once again, let me restate the risks of crashing netgames or 
  168. entire networks by improper use of IPX primatives.  Don't 
  169. experiment with programs using this specification on live
  170. sockets or networks.  We disclaim all responsibility for 
  171. improper use of this specification.
  172.  
  173. For more information on IPX interrupts, headers, etc, I'd
  174. recommend "C Programmers Guide to NetBIOS, SPX, and IPX"
  175. published by Sams.
  176.  
  177. Happy hacking.
  178.  
  179.